/*
 ============================================================================
 Page	     : 158
 Name        : zeno.c
 Date	     : 20210403
 Author      : Hbue 18060333
 Copyright   : Your copyright notice
 Description : 求序列的和
 ============================================================================
 */

#include <stdio.h>

int main(void)
{
	int t_ct = 0;		// 项计数
	int limit = 0;
	double time = 0;
	double power_of_2;

	printf("Enter the number of terms you want: ");
	scanf("%d", &limit);
	for(time = 0, power_of_2 = 1, t_ct = 1; t_ct <= limit; t_ct++, power_of_2 *= 2.0)
	{
		time += 1.0 / power_of_2;
		printf("time = %f when terms = %d.\n",time, t_ct);
	}
	
	return 0;
}

